//
//  AdviceViewController.m
//  ReactiveCocoa
//
//  Created by admin on 2022/3/23.
//

#import "AdviceViewController.h"
#import "JKLimitInput.h"
#import "UITextView+JKExtension.h"
#import <Masonry/Masonry.h>
#import "UIViewController+HUD.h"
@interface AdviceViewController ()<UITextViewDelegate>
@property (nonatomic,strong)UITextView *textView;
@property (nonatomic,strong)UIButton *submmitButton;
@property (nonatomic,strong)UIView *textLayer;

@end

@implementation AdviceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"意见反馈";
    [self initView];
    
    // Do any additional setup after loading the view.
}
-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)submmitAction{
    
    if ([self.textView.text isEqualToString:@""]||self.textView.text == nil) {
        
        [self showHint:@"意见不能为空"];
        return;
    }
    [self showHint:@"提交成功"];
    [self.navigationController popViewControllerAnimated:YES];
    
}
-(void)initView{
    
    [self.view addSubview:self.textLayer];
    [self.textLayer mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.view.mas_top).offset(5);
        make.left.mas_equalTo(self.view.mas_left).offset(5);
        make.right.mas_equalTo(self.view.mas_right).offset(-5);
        make.height.mas_equalTo(125);
        
    }];
    
    [self.textLayer addSubview:self.textView];
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.view.mas_top).offset(15);
        make.left.mas_equalTo(self.view.mas_left).offset(15);
        make.right.mas_equalTo(self.view.mas_right).offset(-15);
        make.height.mas_equalTo(115);
        
    }];
    [self.view addSubview:self.submmitButton];
    [self.submmitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(55);
        make.right.equalTo(self.view).offset(-55);
        make.height.mas_equalTo(40);
        make.top.equalTo(self.textView.mas_bottom).offset(100);
    }];
}
-(UIView *)textLayer{
    
    if (_textLayer == nil) {
        
        _textLayer = [[UIView alloc]init];
        _textLayer.layer.borderColor = [UIColor colorWithRed:249/255.0 green:249/255.0 blue:249/255.0 alpha:1].CGColor;
        _textLayer.layer.borderWidth = 5;
        _textLayer.layer.cornerRadius = 7;
        _textLayer.clipsToBounds = YES;
    }
    return _textLayer;
}
- (UIButton *)submmitButton {
    if (!_submmitButton) {
        _submmitButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_submmitButton setTitle:@"提交" forState:UIControlStateNormal];
        [_submmitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _submmitButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        _submmitButton.layer.cornerRadius = 20;
        _submmitButton.layer.masksToBounds = YES;
        _submmitButton.backgroundColor = [UIColor colorWithRed:72/255.0 green:142/255.0 blue:255/255.0 alpha:1];
        [_submmitButton addTarget:self action:@selector(submmitAction) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
    }
    
    return _submmitButton;
}
-(UITextView *)textView{
    
    if (_textView == nil) {
        
        _textView = [[UITextView alloc]init];
        [_textView jk_addPlaceHolder:@"请输入意见"];
       
    }
    return _textView;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
